﻿@model DNA.OpenAPI.Atom.AtomFeed
@{
    Ajax.Dna().Widget()
        .Content(@<text>
    @if (Model.Entries.Count > 0)
    {
        if (item.GetData<bool>("ShowFeedInfo"))
        { 
        <table style="width: 100%;">
            <tr>
                <td valign="top">
                    @if (!string.IsNullOrEmpty(Model.Logo))
                    {
                        <img src="@Model.Logo" alt="logo" />
                    }
                </td>
                <td valign="top">
                    <h2>
                        @Model.Title</h2>
                    <div>
                        @Model.CopyRight</div>
                </td>
            </tr>
            @if (Model.Links.Count > 0)
            {
                <tr>
                    <td colspan="2">
                        <div>
                            Links:</div>
                        @Html.ImageLinkList().Options(opts =>
                                   {
                                       opts.CssClass = "ui-helper-reset"; opts.ItemCssClass = "ui-helper-reset";
                                       opts.ItemCssStyleText = "clear:left;margin-right:5px;"; opts.TitleCssStyleText = "padding-top:2px;";
                                   }).Items(items =>
                                   {
                                       foreach (var link in Model.Links)
                                       {
                                           items.Add((string.IsNullOrEmpty(link.Text) ? link.NavigateUrl : link.Text), Url.Content("~/Content/Images/permalink.gif"), link.NavigateUrl);
                                       }
                                   }).Render()
                    </td>
                </tr>
            }
        </table>
        }
        var _layout = "_Atom" + item.GetString("Layout");
        var viewdata = new ViewDataDictionary();
        viewdata["TextLen"] = item.UserPreferences["TextLen"];
        viewdata["ShowAuthor"] = item.UserPreferences["ShowAuthor"];
        viewdata["ShowDate"] = item.UserPreferences["ShowDate"];
        var rows = item.GetInt("Rows") > 0 ? item.GetInt("Rows") : 5;
        var feedItems = Model.Entries.Count > rows ? Model.Entries.Take(rows) : Model.Entries;
        @Html.Partial(_layout, feedItems, viewdata)
        <div style="clear: left;">
        </div>
    }
    else
    {
        <div style="padding: 15px;">
            @Html.Global("Feed_Empty")
        </div>
    }
    </text>)
        .Render();
}
